﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../common/jsp/taglibs.jsp"%>
<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>检验-车间入库检验</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<%@ include file="../../common/jsp/config.jsp"%>
<%@ include file="../../common/jsp/validate.jsp"%>
<script type="text/javascript" src="common/js/calendar/WdatePicker.js" ></script>
<script type="text/javascript">
	$.validator.setDefaults({
		submitHandler: function(validator, form) {
			var result = saveSubmit();
			if (result) {
				form.submit();
			}
			return false;
		}
	});
	$(document).ready(function() {
		$("#saveInStoreVoucherCheckResult").validate();
	});

	function saveSubmit() {
		var allIsCurrent = true;
		$("td[id^='detailNumber-']").each(function(i){
			var id = this.id;
			var acceptId = id.replace("detailNumber-", "acceptNumbers-");
			var otherId = id.replace("detailNumber-", "otherNumbers-");
			var detailValue = parseFloat($(this).html());
			var acceptValue = parseFloat($("#" + acceptId).val());
			var otherValue = parseFloat($("#" + otherId).val());
			if (detailValue != acceptValue + otherValue) {
				allIsCurrent = false;
			}
		});

		if (!allIsCurrent) {
			alert("检验数量和送检数量不符，无法保存");
			return false;
		}
		return true;
	}
</script>
</HEAD>
<BODY>
    <s:form action="saveInStoreVoucherCheckResult">
    <s:hidden name="voucherId" value="%{voucher.id}" />
    <div class="subnav" align="left">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">检验</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">车间入库检验</span></td>
		  </tr>
		</table>
      </div>
     <div class="main_1">
       <table width="99%" border="0" cellpadding="10" cellspacing="1" bgcolor="#D3DEEF">
         <tr>
           <td align="left" class="Blue14" bgcolor="#FAFAFA" colspan="4">入库单信息</td>
         </tr>
         <tr>
		    <td width="20%" bgcolor="#FAFAFA" align="right"><strong>入库单号</strong></td>
		    <td width="30%" bgcolor="#FAFAFA"><s:property value="voucher.id"/></td>
		    <td width="20%" bgcolor="#FAFAFA" align="right"><strong>部门</strong></td>
	        <td width="30%" bgcolor="#FAFAFA"><s:property value="voucher.deptName"/></td>
		 </tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>送检日期</strong></td>
	      <td bgcolor="#FAFAFA"><s:date name="voucher.createDate" format="yyyy-MM-dd"/></td>
	      <td bgcolor="#FAFAFA" align="right"><strong>送检人</strong></td>
	      <td bgcolor="#FAFAFA"><s:property value="voucher.person"/></td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>检验日期</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="voucher.checkDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" size="10" cssClass="{required:true}"/>
			<span class="red-text1">*</span>
		  </td>
	      <td bgcolor="#FAFAFA" align="right"><strong>检验单号</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="voucher.checkNo" size="20" cssClass="{required:true,maxlength:20}"/>
			<span class="red-text1">*</span>
		  </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>检验结果</strong></td>
	      <td bgcolor="#FAFAFA">
	      	<s:radio list='#{"合格":"合格", "不合格":"不合格", "宽放":"宽放", "特采放行":"特采放行"}' name="voucher.checkResult"></s:radio>
	      	<span class="red-text1">*</span>
	      </td>
	      <td bgcolor="#FAFAFA" align="right"><strong>检验人</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="voucher.checker" size="10" cssClass="{required:true,maxlength:10}"/>
			<span class="red-text1">*</span>
		  </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>原因描述</strong></td>
	      <td bgcolor="#FAFAFA" colspan="3"><s:textarea name="voucher.checkDescribe" rows="5" cssClass="textarea2"/></td>
		</tr>
      </table>
     </div>
     <div class="clear"></div>
	 <div class="main_scroll">
       <table width="925px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a" id="productList">
        <tr class="ksglxx2bg">
          <th width="50px" >大分类</th>
          <th width="60px" >中分类</th>
          <th width="95px" >名称</th>
          <th width="180px" >型号</th>
          <th width="180px" >其他</th>
		  <th width="50px">单位</th>
		  <th width="95px">生产批号</th>
		  <th width="65px">送检数量</th>
		  <th width="75px">合格数量</th>
		  <th width="75px">不合格数量</th>
		</tr>
		<s:iterator value="voucher.voucherDetails" id="detail" status="st">
          <s:if test="#st.Odd">
            <tr class="odd">
          </s:if>
          <s:else>
            <tr class="even">
          </s:else>
              <td><s:property value="#detail.productRootCategory" /></td>
              <td><s:property value="#detail.productCategory" /></td>
              <td><s:property value="#detail.productName" /></td>
              <td><s:property value="#detail.productType" /></td>
              <td><s:property value="#detail.productSku" />
                  <s:hidden name="detailIds" value="%{#detail.id}" /></td>
              <td><s:property value="#detail.unit" /></td>
              <td><s:property value="#detail.batchNo" /></td>
              <td id='detailNumber-<s:property value="#st.index" />'><s:property value="#detail.number" /></td>
              <td>
                <s:textfield id='acceptNumbers-%{#st.index}' name="acceptNumbers" value="%{#detail.number}" size="6" 
					cssClass="{required:true,maxlength:10,number:true}"/>
			  </td>
              <td>
                <s:textfield id='otherNumbers-%{#st.index}' name="otherNumbers" value="0" size="6" 
					cssClass="{required:true,maxlength:10,number:true}"/>
			  </td>
            </tr>
		</s:iterator>
       </table>
      </div>
     <div class="clear"></div>
	 <div class="main_1">
		<table width="98%" border="0" cellpadding="5" cellspacing="0" class="gr-text1">
		   <tr>
			 <td width="45%" align="right">
			   <s:submit value="保存" cssClass="input1" />&nbsp;&nbsp;
			   <input type="button" value="关闭" class="input1" onclick='javascript:window.location.href="inStoreVoucherWaitCheckList.action"' /></td>
			 <td width="55%" align="left"></td>
		   </tr>
	   </table>
	</div>
	<div class="clear"></div>
	</s:form>
</BODY></HTML>
